package cn.jasonone.bbs.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.jasonone.bbs.bean.UserInfo;
import cn.jasonone.bbs.mapper.UserInfoMapper;
import cn.jasonone.bbs.service.UserInfoService;

@Service("userInfoService")
public class UserInfoServiceImpl implements UserInfoService {
	@Resource
	private UserInfoMapper userInfoMapper;

	@Override
	public List<UserInfo> findAll(UserInfo t) {
		return userInfoMapper.findAll(t);
	}

	@Override
	public UserInfo findByID(Long id) {
		return userInfoMapper.findByID(id);
	}

	@Override
	public boolean insert(UserInfo t) {
		// TODO Auto-generated method stub
		return userInfoMapper.insert(t) > 0;
	}

	@Override
	public boolean update(UserInfo t) {
		return userInfoMapper.update(t) > 0;
	}

	@Override
	public boolean delete(UserInfo t) {
		return userInfoMapper.delete(t) > 0;
	}

	@Override
	public String findByName(String username) {
		String msg = "";
		List<UserInfo> list = userInfoMapper.findByName(username);
		if(list.size()==0) {
			msg = "账号不存在!";
			return msg;
		}else {
			msg = "账号正确";
		}
		return msg;
	}


	@Override
	public UserInfo login(UserInfo userinfo) {
		return userInfoMapper.login(userinfo);
	}

}
